

//var url = 'http://localhost:8080/jhtj/';
//
//Ext.BLANK_IMAGE_URL = url + 'ext/resources/images/default/s.gif';
//Ext.SSL_SECURE_URL= url + 'ext/resources/images/default/s.gif';

//url += 'JarpListener?className=com.jsepc.jhtj.powerGridDev.ProjectPag';
//url += '&methodName=getSydq';
//url += '&paramCount=1';
//url += '&param_0=' ; 



Ext.onReady(function(){

      var tree = new Ext.tree.TreePanel({
                        id:'im-tree',
                        title: "",
                        loader: new Ext.tree.TreeLoader({
                        		dataUrl: basePath+'JarpListener?className=com.jsepc.jhtj.powerGridDev.ProjectPag&methodName=getAllXmxx&paramCount=2&param_0='+baoxh+'&param_1='+dwdm,
                        		baseAttrs: { uiProvider: Ext.tree.TreeCheckNodeUI }
                        	}),
                        rootVisible:false,
                        lines:false,
                        iconCls:'nav',
                        checkModel: 'multiple',   //对树的级联多选  
						onlyLeafCheckable: false,//对树所有结点都可选 
                        autoScroll:true,
                        root: new Ext.tree.AsyncTreeNode({text:"江苏省"})
                         ,buttons: [{
					            text: '保存',            
					            handler: function(){
						        	saveForm();
						        }
					        },{
					            text: '返回',
					            handler: function(){
						        	guanbi();
						        }
					        }]    
        });
        if(dwdm!=null&&dwdm.length>0){
       		tree.root.expand(true);
       		
      	 }
   		tree.on("check",function(node,checked){
   			//var id=node.id;
   			//var name=node.text;
   			
   		}); 
       		
       		
       		
       tree.render("tree_id");
       
       tree.on("beforeload",function(node){
       		node.loader = new Ext.tree.TreeLoader({
       				dataUrl:basePath+'JarpListener?className=com.jsepc.jhtj.powerGridDev.ProjectPag&methodName=getAllXmxx&paramCount=2&param_0='+baoxh+'&param_1='+dwdm,
       				baseAttrs: { uiProvider: Ext.tree.TreeCheckNodeUI }
               }) ;
       },this,true);
       
       
       
       function guanbi(){
       		window.returnValue = null;
       		window.close();
       }
      
       function saveForm(){
       		var lst = tree.getChecked();
       		var lst1 = tree.nodes;
       		//alert(lst1);
       		var dwmc="";
			var dwdm="";
       		for(var i=0;i<lst.length;i++){
                var node = lst[i];
                dwdm+=","+node.id;
                dwmc+=","+node.text;
            }
            if(lst.length>0){
    	   		window.returnValue =dwdm.substring(1,dwdm.length)+"&"+dwmc.substring(1,dwmc.length);
    	   	}else{
    	   		window.returnValue = null;
    	   	}
    	   	window.close();
       }
});